package com.caifeng.myapplication.expandableList;

import android.os.Bundle;
import android.widget.ExpandableListView;

import androidx.appcompat.app.AppCompatActivity;

import com.caifeng.myapplication.R;

import java.util.ArrayList;
import java.util.List;

public class DemoExpandable extends AppCompatActivity {

    ExpandableListView expandableListView;
    List<GroupBean> mList;
    GroupBeanAdapter groupBeanAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.ex_list);

        expandableListView=findViewById(R.id.ex_list);
        groupBeanAdapter=new GroupBeanAdapter(getData(),DemoExpandable.this);
        expandableListView.setAdapter(groupBeanAdapter);


    }

    public List<GroupBean> getData() {
        mList=new ArrayList<>();
        GroupBean groupBean=new GroupBean();
        groupBean.setGr_online("2");
        groupBean.setGr_title("111");
        groupBean.setGr_totalPerson("3");

        List<GroupBean.ChildBean> childBeanList=new ArrayList<>();
        GroupBean.ChildBean childBean=groupBean.new ChildBean();
        childBean.setAcatarid(R.mipmap.ic_launcher);
        childBean.setName("123");
        childBean.setOnline("4");
        childBean.setText("wu");
        childBeanList.add(childBean);


        childBean=groupBean.new ChildBean();
        childBean.setAcatarid(R.mipmap.ic_launcher);
        childBean.setName("123");
        childBean.setOnline("4");
        childBean.setText("wu");
        childBeanList.add(childBean);

        groupBean.setmList(childBeanList);
        mList.add(groupBean);



        return mList;
    }
}
